#include<bits/stdc++.h>
using namespace std;
#define OK 1
#define ERROR 0
typedef int Status;
typedef struct LNode{
	int data;
	LNode *next;	
}LNode, *LinkList; 
Status Init(LinkList &L)
{
	L = new LNode;
	if(!L) return ERROR;
	L->next = NULL;
	return OK;
}
Status Create(LinkList &L, int n)
{
	LNode *t = L;
	for(int i = 0; i < n; i ++)
	{
		LNode *p = new LNode;
		if(!p) return ERROR;
		cin >> p->data;
		p->next = t->next;
		t->next = p;
		t = p;
	}
	return OK;
}
void MergeList(LinkList &L1, LinkList &L2)
{
	/***************Begin**************/
    LNode *p1 = L1->next, *p2 = L2->next;
	L1->next = NULL;
	
	while(p1 && p2)
	{
		if(p1->data <= p2->data)
		{
			LNode *q = p1->next;
			p1->next = L1->next;
			L1->next = p1;
			p1 = q;
		}
		else
		{
			LNode *q = p2->next;
			p2->next = L1->next;
			L1->next = p2;
			p2 = q;
		}
	}
	if(p1) p2 = p1;
	while(p2)
	{
			LNode *q = p2->next;
			p2->next = L1->next;
			L1->next = p2;
			p2 = q;
	}
	delete L2;
    /***************End*****************/
}
void Show(LinkList L)
{
	LNode *p = L->next;
	while(p)
	{
		cout << p->data << ' ';
		p = p->next;
	}
	cout << endl;
}
int main()
{
	LinkList L1, L2;
	Init(L1);
	Init(L2);
	
	int n1, n2;
	cin >> n1 >> n2;
	
	Create(L1, n1);
	Create(L2, n2);
	
	MergeList(L1, L2);
	 
	Show(L1);
	return 0;
}